<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>pymsn.client</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://telepathy.freedesktop.org/wiki/Pymsn">pymsn</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;pymsn ::
        Module&nbsp;client
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module client</h1><p class="nomargin-top"><span class="codelink"><a href="pymsn.client-pysrc.html">source&nbsp;code</a></span></p>
<p>Client</p>
  <p>This module contains the main class used to login into the MSN 
  Messenger network. The following example demonstrates a simple 
  client.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">import</span> pymsn
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span>server = (<span class="py-string">'messenger.hotmail.com'</span>, 1863)
<span class="py-prompt">&gt;&gt;&gt; </span>account = (<span class="py-string">'pymsn@hotmail.com'</span>, <span class="py-string">'pymsn is great !'</span>)
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span>client = pymsn.Client(server)
<span class="py-prompt">&gt;&gt;&gt; </span>client.login(*account)
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">if</span> __name__ == <span class="py-string">&quot;__main__&quot;</span>:
<span class="py-more">... </span>    <span class="py-keyword">import</span> gobject
<span class="py-more">... </span>    <span class="py-keyword">import</span> logging
<span class="py-more">... </span>    logging.basicConfig(level=logging.DEBUG) <span class="py-comment"># allows us to see the protocol debug</span>
<span class="py-more">...</span>
<span class="py-more">... </span>    mainloop = gobject.MainLoop()
<span class="py-more">... </span>    mainloop.run()</pre>
  <p>This client will try to login, but will probably fail because of the 
  wrong password, so let's enhance this client so that it displays an error
  if the password was wrong, this will lead us to use the <a 
  href="pymsn.event-module.html" class="link">pymsn.event</a> 
  interfaces:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">import</span> pymsn
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">import</span> pymsn.event
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">class</span> <span class="py-defname">ClientEventHandler</span>(pymsn.event.ClientEventInterface):
<span class="py-more">... </span>    <span class="py-keyword">def</span> <span class="py-defname">on_client_error</span>(self, error_type, error):
<span class="py-more">... </span>        <span class="py-keyword">if</span> error_type == pymsn.event.ClientErrorType.AUTHENTICATION:
<span class="py-more">... </span>            <span class="py-keyword">print</span> <span class="py-string">&quot;&quot;</span>
<span class="py-more">... </span>            <span class="py-keyword">print</span> <span class="py-string">&quot;********************************************************&quot;</span>
<span class="py-more">... </span>            <span class="py-keyword">print</span> <span class="py-string">&quot;* You bummer ! you did input a wrong username/password *&quot;</span>
<span class="py-more">... </span>            <span class="py-keyword">print</span> <span class="py-string">&quot;********************************************************&quot;</span>
<span class="py-more">... </span>        <span class="py-keyword">else</span>:
<span class="py-more">... </span>            <span class="py-keyword">print</span> <span class="py-string">&quot;ERROR :&quot;</span>, error_type, <span class="py-string">&quot; -&gt;&quot;</span>, error
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span>server = (<span class="py-string">'messenger.hotmail.com'</span>, 1863)
<span class="py-prompt">&gt;&gt;&gt; </span>account = (<span class="py-string">'pymsn@hotmail.com'</span>, <span class="py-string">'pymsn is great !'</span>)
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span>client = pymsn.Client(server)
<span class="py-prompt">&gt;&gt;&gt; </span>client_events_handler = ClientEventHandler(client)
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span>client.login(*account)
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">if</span> __name__ == <span class="py-string">&quot;__main__&quot;</span>:
<span class="py-more">... </span>    <span class="py-keyword">import</span> gobject
<span class="py-more">... </span>    <span class="py-keyword">import</span> logging
<span class="py-more">...</span>
<span class="py-more">... </span>    logging.basicConfig(level=logging.DEBUG) <span class="py-comment"># allows us to see the protocol debug</span>
<span class="py-more">...</span>
<span class="py-more">... </span>    mainloop = gobject.MainLoop()
<span class="py-more">... </span>    mainloop.run()</pre>

<!-- ==================== CLASSES ==================== -->
<a name="section-Classes"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Classes</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="pymsn.client.Client-class.html" class="summary-name">Client</a><br />
      This class provides way to connect to the notification server as 
        well as methods to manage the contact list, and the personnal 
        settings.
    </td>
  </tr>
</table>
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://telepathy.freedesktop.org/wiki/Pymsn">pymsn</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Aug  2 15:19:16 2009
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
